package vuelos;

import java.awt.BorderLayout;
import javax.swing.JDesktopPane;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import java.sql.Connection;


@SuppressWarnings("serial")
public class MainWindow extends javax.swing.JFrame 
{

   private JDesktopPane jDesktopPane1;
   
   private LoginScreen Login;   
   private ClientScreen Cliente;
   private AdminScreen Admin;
   private EmployeScreen Empleado;
   
   private Connection conexionBD = null;
   
   // Main Metod
   public static void main(String[] args) 
   {
      SwingUtilities.invokeLater(new Runnable() {
         public void run() {
            MainWindow inst = new MainWindow();
            inst.setLocationRelativeTo(null);
            inst.setVisible(true);
         }
      });
   }
   
   // Constructor
   public MainWindow() 
   {
      super();

      initGUI();
      
      this.Cliente = new ClientScreen(this);
      this.jDesktopPane1.add(this.Cliente);
      
      this.Admin = new AdminScreen(this);
      this.jDesktopPane1.add(this.Admin);
      
      this.Empleado = new EmployeScreen(this);
      this.jDesktopPane1.add(this.Empleado);
      
      this.Login = new LoginScreen(this);
      this.jDesktopPane1.add(this.Login);
      this.Login.traer();

   }
   
   // Init Components
   private void initGUI() 
   {
      try 
      {
         javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
      } 
      catch(Exception e) 
      {
         e.printStackTrace();
      }
      
      try {
         {
            this.setTitle("Airpot Terminal");
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
         }
         {
            jDesktopPane1 = new JDesktopPane();
            getContentPane().add(jDesktopPane1, BorderLayout.CENTER);
            jDesktopPane1.setPreferredSize(new java.awt.Dimension(800, 600));            
            jDesktopPane1.setBorder(new Backgroud("/images/Background.jpg"));            
         }
 
         this.setSize(800, 600);
         this.setResizable(false);
         pack();
         
      } catch (Exception e) {
         e.printStackTrace();
      }
   } 
   
   public void setConnection(Connection Cnx) {
	   conexionBD = Cnx; 	   
   }
   
   public Connection getConnection() {
	   return conexionBD;
   }
   
   public void showLoginWindow() {
	   Login.traer();
   }
   
   public void showClientWindow(String usuarioLLamador) {
	   Cliente.traer(usuarioLLamador);
   }
   
   public void showEmployeWindow(String usuarioLLamador) {
	   Empleado.traer(usuarioLLamador);
   }
   
   public void showAdminWindow(String usuarioLLamador) {
	   Admin.traer(usuarioLLamador);
   }
    
}